package Database;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class DelDbFunctions 
{
	public static void delUser(Integer id)
	{
		Connection con;
		PreparedStatement ps;
		int rs;
		String statement;
		
		try
		{
			con = Connector.getConnection();
			
			statement = "DELETE FROM USER WHERE ID = " + id;
			ps = con.prepareStatement(statement);

			rs = ps.executeUpdate();
			
			if(rs != 1)
				System.out.println("Vymazanie nebolo uspesne");
			
			ps.close();
			con.close();
		}
		catch (SQLException e)
		{
			e.printStackTrace();
		}
	}
	
	public static void delAccount(Integer id)
	{
		Connection con;
		PreparedStatement ps;
		int rs;
		String statement;
		
		try
		{
			con = Connector.getConnection();
			
			statement = "DELETE FROM ACCOUNT WHERE ID = " + id;
			ps = con.prepareStatement(statement);
			
			rs = ps.executeUpdate();
			
			if(rs != 1)
				System.out.println("Vymazanie nebolo uspesne");
			
			ps.close();
			con.close();
		}
		catch (SQLException e)
		{
			e.printStackTrace();
		}
	}
	
	public static void delCategory(Integer id)
	{
		Connection con;
		PreparedStatement ps;
		int rs;
		String statement;
		
		try
		{
			con = Connector.getConnection();
			
			statement = "DELETE FROM CATEGORY WHERE ID = " + id;
			ps = con.prepareStatement(statement);
			
			rs = ps.executeUpdate();
			
			if(rs != 1)
				System.out.println("Vymazanie nebolo uspesne");
			
			ps.close();
			con.close();
		}
		catch (SQLException e)
		{
			e.printStackTrace();
		}
	}
	
//	public static void delSubcategory(Integer id)
//	{
//		Connection con;
//		PreparedStatement ps;
//		int rs;
//		String statement;
//		
//		try
//		{
//			con = Connector.getConnection();
//			
//			statement = "DELETE FROM SUBCATEGORY WHERE ID = " + id;
//			ps = con.prepareStatement(statement);
//			
//			rs = ps.executeUpdate();
//			
//			if(rs != 1)
//				System.out.println("Vymazanie nebolo uspesne");
//			
//			ps.close();
//			con.close();
//		}
//		catch (SQLException e)
//		{
//			e.printStackTrace();
//		}
//	}
}
